<template>
  <div class="photoinfo-container">
    <h3>{{ photoinfo.title }}</h3>
    <p class="subtitle">
      <span>发表时间:{{ photoinfo.add_time }}</span>
      <span>点击次数:{{ photoinfo.click }}</span>
    </p>

    <hr />

    <!-- 图片缩略图 -->
    <vue-preview :slides="slide1" @close="handleClose"></vue-preview>

    <!-- 图片内容区域 -->
    <div class="content">{{photoinfo.content}}</div>

    <!-- 评论子组件 -->
    <cmt-box :id="id"></cmt-box>
  </div>
</template>

<script>
import comment from '../subcomponents/comment.vue'
export default {
  data() {
    return {
      id: this.$route.params.id, //从路由中获取到的图片id
      photoinfo: {
        id: 1,
        title: "清新有活力的公寓设计，用色彩焕然一新",
        click: 3,
        add_time: "2021-2-13 13:14:56",
        content:
          "如果代码上没有冲突，但是提交的时候git提醒有冲突，那么先关闭编辑器，然后编译代码找到冲突，最后手动合并代码解决冲",
      }, //图片详情
      slide1: [
          {
            src: 'https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_b.jpg',
            msrc: 'https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_m.jpg',
            alt: 'picture1',
            title: 'Image Caption 1',
            w: 600,
            h: 400
          },
          {
            src: 'https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_b.jpg',
            msrc: 'https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_m.jpg',
            alt: 'picture2',
            title: 'Image Caption 2',
            w: 1200,
            h: 900
          }
        ]
    };
  },
  created() {
    // this.getPhotoInfo();
  },
  components:{
      'cmt-box' : comment
  },
  methods: {
    getPhotoInfo() {
      this.$http.get("api/getthumimages/" + this.id).then((result) => {
        if (result.body.status === 0) {
          this.photoinfo = result.body.message[0];
        }
      });
    },
    handleClose () {
        console.log('close event')
      }
  },
};
</script>

<style lang="scss" scoped>
.photoinfo-container {
  padding: 3px;
  h3 {
    text-align: center;
    color: #26A2FF;
    font-size: 16px;
    margin: 15px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }
  .content{
      font-size: 13px;
      line-height: 30px;
  }
}
</style>